package com.michael.demos.springboot.common.result;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 类功能描述:
 * <pre>
 *   Controller 结果集 JSON格式
 * </pre>
 *
 * @author Michael
 * @version 1.0
 * @date 2020/7/29 10:26
 */
@Data
public class JsonResult<T extends Serializable> implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 请求结果码 */
    @Accessors(chain = true)
    private Integer code;

    /** 请求结果说明 */
    @Accessors(chain = true)
    private String msg;

    /** 请求结果数据 */
    @Accessors(chain = true)
    private T data;

    public JsonResult(JsonResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
    }

    public JsonResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
